package com.qfedu.og.service.impl;

import com.qfedu.og.dao.CompanyDao;
import com.qfedu.og.entity.Company;
import com.qfedu.og.service.intf.CompanyService;
import com.qfedu.og.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: OnlyGroup
 * @description:
 * @author: Feri(邢朋辉)
 * @create: 2021-03-25 14:46
 */
@Service //Spring IOC 反转
public class CompanyServiceImpl implements CompanyService {
    @Autowired //自动注入 前提 当前类的对象
    private CompanyDao dao;

    @Override
    public R save(Company company) {
        if(company!=null && company.getName()!=null) {
            if (dao.insert(company) > 0) {
                return new R(0, "OK", null);
            } else {
                return new R(1, "FAIL", null);
            }
        }else {
            return new R(1, "FAIL", null);
        }
    }
    @Override
    public R all() {
        return new R(0, "OK", dao.all());
    }

    @Override
    public R queryById(int id) {
        return new R(0, "OK", dao.selectById(id));
    }
}
